package com.mapper;

public interface UsersMapper {

    int deleteByPrimaryKey(Long id);

    <Users> int insert(Users record);

    <Users> int insertSelective(Users record);

    <Users> Users selectByPrimaryKey(Long id);

    <Users> int updateByPrimaryKeySelective(Users record);

    <Users> int updateByPrimaryKey(Users record);

    <Users> Users findUserWithOrders(Integer id);

    @Select("select *from mybatis.tb_user where id=#{id}")
    @Results({
            @Result(id = true ,column = "id",property = "id"),
            @Result(id = true ,column = "username",property = "username"),
            @Result(id = true ,column = "address",property = "address"),
            @Result(id = true ,column = "id",property = "ordersList",many = @Many(
                    select = "com.mapper.OrdersMapper.selectOrdersByUserId"
            ))

    })
    <Users>
    Users selectUserById(int id);
}
